package com.rapid.maintenance.ui.activity.productmall;

import android.app.Activity;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.core.app.ActivityOptionsCompat;
import androidx.core.util.Pair;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.rapid.maintenance.R;
import com.rapid.maintenance.adapter.NewsAdapter;
import com.rapid.maintenance.base.BaseActivity;

import butterknife.BindView;

public class ProductMallBusinessNewsActivity extends BaseActivity {
    @BindView(R.id.iv_bg)
    ImageView ivBg;
    @BindView(R.id.shoucang)
    TextView shoucang;
    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.iv_logo)
    ImageView ivLogo;
    @BindView(R.id.ll_logo)
    LinearLayout llLogo;
    @BindView(R.id.header)
    RelativeLayout header;
    @BindView(R.id.news)
    RecyclerView news;
    private NewsAdapter adapter;

    @Override
    protected int provideRootLayout() {
        return R.layout.activity_product_mall_business_news;
    }

    @SuppressWarnings("unchecked")
    private <T extends Activity> void jumpChildActivity(Class<T> aClass) {
        Pair<View, String> toolbar = new Pair<>(getToolbar(), "all_main_toolbar");
        Pair<View, String> statusbar = new Pair<>(getStatusBar(), "status_bar");
        Pair<View, String> header = new Pair<>(this.header, "header");
        ActivityOptionsCompat aoc = ActivityOptionsCompat.makeSceneTransitionAnimation(this, toolbar, statusbar, header);
        startActivity(aClass, aoc.toBundle());
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        return super.onKeyDown(keyCode, event);
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    protected void init() {
        setTitle("新闻资讯");
        setStatusBarColor(0xFF016DB6);
        setToolBarColor(0xFF016DB6);

        news.setAdapter(adapter = new NewsAdapter());
        adapter.addData(new Object());
        adapter.addData(new Object());
        adapter.addData(new Object());
        adapter.addData(new Object());
        adapter.addData(new Object());
        adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                jumpChildActivity(ProductMallBusinessNewsDetailActivity.class);
            }
        });
    }

}
